@namespace SwashbucklerDiary.Rcl.Pages
@inherits ImportantComponentBase

<MCard Class="my-list-card"
       Elevation="0"
       Rounded="@("lg")">
    <MList>
        <MListItem OnClick="()=>showConfig=true">
            <MListItemIcon>
                <MIcon Class="evident-icon">
                    mdi-cog-sync-outline
                </MIcon>
            </MListItemIcon>

            <MListItemContent>
                <MListItemTitle>
                    @(I18n.T("Backups.Config.Title"))
                </MListItemTitle>
            </MListItemContent>

            <MListItemContent>
                <MListItemSubtitle Class="text-right">
                    @ConfiguredText
                </MListItemSubtitle>
            </MListItemContent>

            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-5"></MDivider>

        <MListItem OnClick="OpenUploadDialog">
            <MListItemIcon>
                <MIcon Class="evident-icon">
                    mdi-cloud-arrow-up-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                <MListItemTitle>
                    @(I18n.T("Backups.Upload.Title"))
                </MListItemTitle>
                <MListItemSubtitle Class="text-caption-xs-only">
                    @(I18n.T("Backups.Backups.Subtitle"))
                </MListItemSubtitle>
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-5"></MDivider>

        <MListItem OnClick="OpenDownloadDialog">
            <MListItemIcon>
                <MIcon Class="evident-icon">
                    mdi-cloud-arrow-down-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                <MListItemTitle>
                    @(I18n.T("Backups.Download.Title"))
                </MListItemTitle>
                <MListItemSubtitle Class="text-caption-xs-only">
                    @(I18n.T("Backups.Restore.Subtitle"))
                </MListItemSubtitle>
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>
    </MList>
</MCard>

<MCard Elevation="0"
       Rounded="@("lg")">
    <MListItem>
        <MListItemIcon>
            <MIcon Class="evident-icon">
                mdi-file-outline
            </MIcon>
        </MListItemIcon>
        <MListItemContent>
            @(I18n.T("Backups.WebDAV.IncludeDiaryResources"))
        </MListItemContent>
        <MListItemAction>
            <SettingSwitch @bind-Value="includeDiaryResources"
                           SettingKey="@nameof(Setting.WebDAVCopyResources)">
            </SettingSwitch>
        </MListItemAction>
    </MListItem>
</MCard>

<WebDavConfigDialog @bind-Visible="showConfig"
                    Form="configModel"
                    OnOK="SaveWebDavConfig">
</WebDavConfigDialog>

<CustomMDialog @bind-MyValue="showUpload"
                  ContentClass="rounded-lg"
                  MaxWidth="420">
    <MCard>
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Backups.Upload.Title"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="@(()=>showUpload=false)">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="pb-0">
            @(I18n.T("Backups.Upload.Content") + webDavFolderName)
        </MCardText>
        <MCardActions>
            <MSpacer></MSpacer>
            <MButton Text="true"
                     OnClick="()=>showUpload=false">
                @(I18n.T("Share.Cancel"))
            </MButton>
            <MButton Text="true"
                     Color="primary"
                     OnClick="Upload">
                @(I18n.T("Share.OK"))
            </MButton>
        </MCardActions>
    </MCard>
</CustomMDialog>

<CustomMDialog @bind-MyValue="showDownload"
                  ContentClass="rounded-lg"
                  MaxWidth="420"
                  Scrollable="true">
    <MCard>
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Backups.Download.Title"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="()=>showDownload=false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="scroll-show pb-0 mb-5"
                   Style="max-height:300px;">
            <Virtualize Items="fileList"
                        ItemSize="56"
                        Context="item">
                <MListItem @key="item"
                           Class="mb-1 rounded"
                           OnClick="()=>Download(item)">
                    <MListItemContent>
                        <MListItemTitle Class="webdav-list-item__title">
                            @item
                        </MListItemTitle>
                    </MListItemContent>
                </MListItem>
            </Virtualize>
        </MCardText>
    </MCard>
</CustomMDialog>

